草庐IT

iOS swift : SearchController with a StoryBoard UISearchBar

全部标签

ios - 为什么在 searchBar 和 tableview 之间添加空白?

我有一个TableViewController。我添加了搜索栏。但是当我点击searchBar时,我在searchBar和TableView之间有一个空白区域?为什么?它是如何修复的?在下面,我添加了代码tableViewController的屏幕截图和列表。感谢您的帮助。!!!!!!-列出TableViewController-!!!!!classAlfavitController:UITableViewController,UISearchResultsUpdating{varsearchController:UISearchController!varresultControll

ios - 如何使用代码将 UISearchController Searchbar 放到导航栏上

如果我将ViewController嵌入到导航栏中,navigationItem.titleView.resultSearchController?.searchBar会将搜索栏放入导航栏中。但是,我用代码创建了一个UISearchController和一个UINavigationBar。这一次,navBar出现了,但searchBar没有出现。resultSearchController=UISearchController(searchResultsController:locationSearchTable)resultSearchController?.searchResult

ios - SearchBar,如何改变文字颜色?

我的搜索栏有默认的灰色文本,但我希望它是白色文本。我无法弄清楚如何使用swift来更改范围栏文本颜色,而且您无法从Storyboard中执行此操作。我找到的最接近的是searchBarOutlet.setScopeBarButtonTitleTextAttributes([NSForegroundColorAttributeName:UIColor.whiteColor()],forState:UIControlState.Normal)但是,唉,这也行不通。有什么想法吗? 最佳答案 访问UISearchbar中的Textfield

swift - 使用彩色导航栏时 SearchBar 出现白线

在搜索栏中单击时出现多条白线。当同时使用TabBarController和彩色条NavigationController时会发生这种情况,但是仅在使用NavigationController时有效它在TabBarController和NavigationController都使用默认颜色时有效我使用这行代码在AppDelegate中设置导航颜色:UINavigationBar.appearance().barTintColor=UIColor(rgb:0x0277BD)UINavigationBar.appearance().titleTextAttributes=[NSAttribu

ios - swift : show searchbar when scroll up and hide it when scroll down

我是Ios开发的新手,我在导航项中添加了一个Searchbar我想要实现的是当我向上滚动tableview我想隐藏Searchbar并在向下滚动时显示它类似于iPAD/Iphone上的safari效果,向下滚动时隐藏地址栏,向上滚动时显示地址栏letsearchController=UISearchController(searchResultsController:nil)searchController.searchResultsUpdater=selfsearchController.obscuresBackgroundDuringPresentation=falsenaviga

swift - UISearchController SearchBar 在旋转期间处于事件状态时未对齐

我已经为UISearchController的搜索栏苦苦挣扎了一段时间。我需要在TableView上实现搜索功能,但与传统方法不同的是,我没有将搜索栏放在表头View上。相反,我创建了一个UIView并将搜索栏添加为它的subview。UIView充当搜索栏的容器,其约束在具有自动布局的Storyboard上正确设置。这是我的代码。请注意,我以编程方式执行此操作,因为从iOS8开始,UISearchDisplayController和UISearchBar已被弃用,取而代之的是UISearchController,并且尚未出现在UIKit中。searchController=UISea

swift - 如何在搜索页面上将searchBar设置为Siri的全局焦点?

描述在我的tvOS应用程序中,我有一个搜索页面,顶部有一个SearchBar,下面有一个TableView,其中包含最终的结果列表。当我们关注searchBar并且用户按下Siri的声音时,结果将插入到搜索栏中(如预期的那样)。但是,当用户向下滚动结果而无法找到他们要查找的内容时,他们必须向上滚动(一直向上滚动)到searchBar才能再次使用Siri。如果用户在searchBar不在焦点上时尝试使用Siri,则全局Siri会开始在不同的应用程序中寻找结果(这不是我想要的)问题:如何在SearchPage上设置searchBar为Siri的全局焦点?我尝试过的:老实说,我不知道该怎么做

ios - 如何覆盖 UISearchController 子类中的 "searchBar"属性?

我遇到这样的问题:HideUISearchBarCancelButton我将UISearchController和UISearchBar子类化,并重写UISearchBar中的方法layoutSubviews。如何在我的自定义UISearchController中使用自定义UISearchBar覆盖searchBar属性?更新1要使用自定义UISearchBar实现属性,我在MyUISearchController中执行:@property(nonatomic,strong,readonly)UISearchBar*searchBar;和@synthesizesearchBar=_se

iphone - 设计 iOS SearchBar

我想在ObjectiveC中有一个简单的SearchBar。使用UISearchBar或UISearchBarDelegate让我感到困惑。我本可以使用UITextField,但它没有搜索栏的外观和感觉。如所附图片所示,我只想要搜索栏,没有UITableView与其相关联。该图像附加了一个TableView,但您明白了。此外,在有人将文本输入搜索栏并按下“输入”后,我该如何检索文本?更新:我知道这些讨论相同内容的链接,但它们更适合使用表格。http://blog.webscale.co.in/?p=228http://ved-dimensions.blogspot.com/2009/0

ios - 当 searchBar 在部分标题中时,UICollectionView reloadData 退出第一响应者/关闭键盘

我有一个具有节标题的UICollectionView。在部分标题中,我有一个UISearchBar。我想在搜索栏中键入内容时过滤我的收藏View中的内容。我使用以下方法执行此操作://ThemethodtochangethepredicateoftheFRC-(void)filterContentForSearchText:(NSString*)searchText{NSString*query=searchText;if(query&&query.length){NSPredicate*predicate=[NSPredicatepredicateWithFormat:@"namec